package com.jinxin.platform.cdacscontrolmgr.controller;

import com.jinxin.platform.base.api.annotation.APCOSApi;
import com.jinxin.platform.base.api.annotation.APCOSApiOperation;
import com.jinxin.platform.base.api.constant.APCOSApiConstans;
import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.cdacscontrolmgr.service.ICdacscontrolkmgrPersonRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * All rights Reserved, Designed By www.beonelot.com
 *
 * @version: V1.0
 * @Copyright: www.beonelot.com Inc. All rights reserved.
 * @Description：
 * @Date: 2021-09-15
 * @Author: Lingnan
 **/
@APCOSApi(value = "门禁行人记录接口", developers = {"lingnan"}, description = "门禁行人记录接口")
@RestController
@RequestMapping("/cdacscontrolmgr/cdacscontrolmgrXrRecord")
@Slf4j
public class CdacscontrolmgrPersonRecordController {
    @Autowired
    ICdacscontrolkmgrPersonRecordService personRecordService;

    @APCOSApiOperation(value = "分页查询行人记录", developers = {"lingnan"}, description = "分页查询行人记录",
            infType = APCOSApiConstans.INF_TYPE_OTHER, infCategory = APCOSApiConstans.INF_CATEGORY_ALL)
    @GetMapping("/list")
    public Map<String,Object> list(@RequestParam int page, @RequestParam int limit,
                                   @RequestParam(name = "projectId")String projectId,
                                   @RequestParam(required = false,name = "openUser")String openUser,
                                   @RequestParam(required = false,name = "phone")String phone,
                                   @RequestParam(required = false,name = "openUserSf")String openUserSf,
                                   @RequestParam(required = false,name = "acsName")String acsName,
                                   @RequestParam(required = false,name = "openType")String openType,
                                   @RequestParam(required = false,name = "startDate")String startDate,
                                   @RequestParam(required = false,name = "endDate")String endDate){
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("code",0);
        resultMap.put("msg","success");
        HashMap param = new HashMap();
        param.put("page", page);
        param.put("limit", limit);
        param.put("projectId", projectId);
        param.put("openUser", openUser);
        param.put("phone", phone);
        param.put("openUserSf", openUserSf);
        param.put("acsName", acsName);
        param.put("openType", openType);
        param.put("startDate", startDate);
        param.put("endDate", endDate);
        resultMap.put("count", personRecordService.listPageCount(param));
        resultMap.put("data", personRecordService.listPage(param));
        return resultMap;
    }

    @APCOSApiOperation(value = "获取门禁列表", developers = {"lingnan"}, description = "获取门禁列表",
            infType = APCOSApiConstans.INF_TYPE_OTHER, infCategory = APCOSApiConstans.INF_CATEGORY_ALL)
    @GetMapping("/listAcsOptions")
    public JsonResult listAcsOptions(String projectId){
        return JsonResult.ok(personRecordService.listAcsOptions(projectId));
    }

}
